home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / hf / dsp / leonid / leonid.asm < prev    next >
Encoding:
Assembly Source File  |  1994-03-13  |  4.2 KB  |  209 lines

  1. ;***************************************************************
  2. ;* LEONID.ASM -- Alef Null DSP CARD 4 monitor interface        *
  3. ;*                                   *
  4. ;* Here are equates for services provided by DSP CARD 4        *
  5. ;* monitor.                               *
  6. ;*                                   *
  7. ;* Copyright (C) 1992-1994 by Alef Null. All rights reserved.
  8. ;* Author(s): Jarkko Vuori, OH2LNS                   *
  9. ;* Modification(s):                           *
  10. ;***************************************************************
  11.  
  12.  
  13. ; Start of the user program and data areas
  14. user_code equ    $0040
  15. user_data equ    $0018
  16.  
  17.  
  18. ; Macro for target system detecting (simulator or DSP CARD 4 platform)
  19. system    macro    target
  20.     if @scp("target",'simulator')!=0
  21. sim_debug
  22.     else
  23.         if @scp("target",'dsp4')==0
  24.         fail "No such system: target, known systems are dsp4 or simulator"
  25.         endif
  26.     endif
  27.     endm
  28.  
  29.  
  30. ; Open serial communication port (reset all buffers)
  31. ;   a - kiss command routine address (zero if not is kiss mode)
  32. ;   b - xmit on/off routine address
  33. opensc    macro
  34.     jsr    <$0020
  35.     endm
  36.  
  37.  
  38. ; Put a byte in x0 to the serial output
  39. putc    macro
  40.     jsr    <$0022
  41.     endm
  42.  
  43.  
  44. ; Request a character from the serial input
  45. ; waits until character given and returns it in x0
  46. getc    macro
  47. _gc1    wait
  48.     jsr    <$0024
  49.     jcs    _gc1
  50.     endm
  51.  
  52.  
  53. ; Look if there are characters waiting at the serial input
  54. ; returns C if there are no data available
  55. ;     NC if there are data, and received data is placed to x0
  56. lookc    macro
  57.     jsr    <$0024
  58.     endm
  59.  
  60.  
  61. ; Test if there are characters waiting at the serial input
  62. ; returns C if there are no data available
  63. ;     NC if there are data available
  64. tstc    macro
  65.     jsr    <$0026
  66.     endm
  67.  
  68.  
  69. ; Terminate KISS output frame
  70. endc    macro
  71.     jsr    <$0028
  72.     endm
  73.  
  74.  
  75. ; Reject KISS output frame
  76. rejc    macro
  77.     jsr    <$002A
  78.     endm
  79.  
  80.  
  81. ; put next bit in C to the host transmit queue
  82. putbit    macro
  83.     jsr    <$002C
  84.     endm
  85.  
  86.  
  87. ; returns next bit to be sent in C
  88. ; returns Z if this is an end of the transmission
  89. getbit    macro
  90.     jsr    <$002E
  91.     endm
  92.  
  93.  
  94. ; Open codec
  95. ; fs is desired sampling rate (8,9.6,16,27.42857,32,48)
  96. opencd    macro    fs
  97.     if @def(sim_debug)==0
  98.         if fs==8
  99.         move                #>$000000,x0
  100.         else
  101.         if fs==9.6
  102.             move            #>$003800,x0
  103.         else
  104.             if fs==16
  105.             move            #>$000800,x0
  106.             else
  107.             if fs==27.42857
  108.                 move        #>$001000,x0
  109.             else
  110.                 if fs==32
  111.                 move        #>$001800,x0
  112.                 else
  113.                 if fs==48
  114.                     move    #>$003000,x0
  115.                 else
  116.                     fail "Illegal sampling rate: fs"
  117.                 endif
  118.                 endif
  119.             endif
  120.             endif
  121.         endif
  122.         endif
  123.         jsr     <$0030
  124.     endif
  125.     endm
  126.  
  127.  
  128. ; Set codecs input and output settings
  129. HEADP    equ    $8000
  130. LINEO    equ    $4000
  131. SPEAKER equ    $0040
  132.  
  133. LINEI    equ    $0000
  134. MIC    equ    $1000
  135.  
  136. ctrlcd    macro    init,reg,len,inputs,lgain,rgain,outputs,loattn,roattn
  137.     if @def(sim_debug)==0
  138.         if        (lgain>22.5)|(rgain>22.5)|(loattn>94.5)|(roattn>94.5)
  139.         fail 'Illegal input gain or output attenuation'
  140.         endif
  141.         move        #(inputs|$f0|(@cvi(lgain/1.5)<<8)|@cvi(rgain/1.5))<<8,x0
  142.         clr     a        #(outputs|(@cvi(loattn/1.5)<<8)|@cvi(roattn/1.5))<<8,x1
  143.         move    (reg)+
  144.         do        #len,_initcs
  145.         if        init
  146.         move        a,y:(reg)+
  147.         move        a,y:(reg)+
  148.         else
  149.         move        (reg)+
  150.         move        (reg)+
  151.         endif
  152.         move        x1,y:(reg)+
  153.         move        x0,y:(reg)+
  154. _initcs
  155.         move    (reg)-
  156.     endif
  157.     endm
  158.  
  159.  
  160. ; Close codec
  161. closecd macro
  162.     jsr    <$0032
  163.     endm
  164.  
  165.  
  166. ; Put byte in x0 to output port
  167. putio    macro
  168.     jsr    <$0036
  169.     endm
  170.  
  171. ; Carrier on
  172. caron    macro
  173.     jsr    <$0038
  174.     endm
  175.  
  176. ; Carrier off
  177. caroff    macro
  178.     jsr    <$003A
  179.     endm
  180.  
  181. ; Wait for the given time (in seconds)
  182. sleep    macro    time
  183.     move            #@cvi(time*9600.0),x0
  184.     jsr    <$0034
  185. _slp1    jset    #4,y:$0002,_slp1
  186.     endm
  187.  
  188.  
  189. ; Macro for waiting specified amount of input data from the codec
  190. waitblk macro    reg,buflen,blklen
  191.     if @def(sim_debug)==0
  192. _loop        wait                    ; wait for a new sample to be received
  193.         move        r7,a
  194.         move        reg,x0
  195.         sub     x0,a    #>blklen*4,x0
  196.         jmi     <_wrap
  197.         cmp     x0,a                ; wp - rp > threshold
  198.         jlo     <_loop
  199.         jmp     <_ok
  200. _wrap        move        #>buflen*4,x1
  201.         add     x1,a                ; buffer wraparound, rp - wp + lenght > threshold
  202.         cmp     x0,a
  203.         jlo     <_loop
  204. _ok
  205.     else
  206.         movep        x:$ffe0,x:(reg)
  207.     endif
  208.     endm
  209.